<!DOCTYPE html>
<html>
<head>
    <title>门店价格账套</title>
    <#include "/header.html">
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <form class="form-inline" role="form">
                <#if shiro.hasPermission("storeFavouredPrice:storefavouredprice:save")>
                <a class="btn btn-primary btn-sm" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
            </#if>
            <!--<#if shiro.hasPermission("storeFavouredPrice:storefavouredprice:update")>-->
            <!--<a class="btn btn-primary btn-sm" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>-->
        <!--</#if>-->
    <!--<div style="float: right">-->
        <!--<span style="color: red">(直接填写折扣的数字,如0.8,1.2)</span>-->
        <!--<input type="number" class="form-control input-sm" v-model="rebate"><a @click="useRebate">使用折扣率</a>-->
    <!--</div>-->
    </form>
</div>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>

<div v-show="!showList&&detailView==false" class="panel panel-default">
    <div class="panel-heading">{{title}}</div>
    <form class="form-horizontal">
        <div class="form-group" v-if="false">
            <div class="col-sm-2 control-label">商户id</div>
            <div class="col-sm-10">
                <input type="text" v-model="storeFavouredPrice.favouredId">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.sellerId" placeholder="商户id" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>账套名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.favouredName" placeholder="账套名称" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>折扣率</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.discountRate" placeholder="折扣率" />
                <span style="color: red">请输入0.1-0.9之间的值</span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>描述</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.describes" placeholder="描述" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>开始时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="storeFavouredPrice.startTime" @click="checkBeginDate" placeholder="开始时间" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>结束时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="storeFavouredPrice.endTime" @click="checkEndDate" placeholder="结束时间" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary  btn-sm" @click="saveOrUpdate" value="确定" />
            &nbsp;&nbsp;<input type="button" class="btn btn-warning  btn-sm" @click="reload" value="返回" />
        </div>
    </form>
    <div class="panel-heading">该账套下的商品折扣率</div>
    <el-table :data="detailData" border style="width: 100%">
        <el-table-column type="index" width="50">
        </el-table-column>
        <el-table-column prop="storeCategoryId" label="商品分类">
        </el-table-column>
        <el-table-column prop="productName" label="商品名称">
        </el-table-column>
        <el-table-column prop="discountRate" label="折扣率">
            <template slot-scope="scope">
                <el-input size="small" v-model="scope.row.discountRate"></el-input>
            </template>
        </el-table-column>
        <el-table-column label="设置阶梯价折扣率" width="200">
            <template slot-scope="scope">
                <!--<el-popover trigger="hover" placement="top">-->
                    <!--<p>{{ scope.row.stepPrice }}</p>-->
                    <!--<div slot="reference" class="name-wrapper">-->
                        <el-button size="small" slot="append" icon="el-icon-setting" @click="openStepPriceDialog(scope.row)">阶梯折扣率设置</el-button>
                    <!--</div>-->
                <!--</el-popover>-->

            </template>
        </el-table-column>
    </el-table>
    <hr>
    <el-row>
        <el-col :span="12">
            <div class="el-form-item">
                <label class="el-form-item__label" style="width: 80px;">商品分类</label>
                <div class="el-form-item__content" style="margin-left: 80px;">
                    <el-cascader style="width: 50%" filterable
                                 v-model="categoryId"
                                 :options="storeCategoryTree"
                                 @change="categoryChange">
                    </el-cascader>
                </div>
            </div>
            <div class="el-form-item">
                <label class="el-form-item__label" style="width: 80px;">商品名称</label>
                <div class="el-form-item__content" style="margin-left: 80px;">
                    <el-select v-model="productId" placeholder="请选择">
                        <el-option
                                v-for="item in storeGoodsProductEntityList"
                                :key="item.productId"
                                :label="item.productName"
                                :value="item.productId">
                        </el-option>
                    </el-select>
                </div>
            </div>
            <div class="el-form-item">
                <el-button-group style="margin-left: 80px">
                    <el-button  size="small" @click="addDetail">添加</el-button>
                    <el-button  size="small" @click="showList=true,detailView=false">取消</el-button>
                </el-button-group>
            </div>
        </el-col>
    </el-row>
</div>
<!--账套详情表start-->
<div v-if="detailView" class="panel panel-default">
        <div class="panel-heading" style="font-size: 14px">门店价格账套明细</div><br>
    <form class="form-horizontal">
        <div class="form-group" v-if="false">
            <div class="col-sm-2 control-label">商户id</div>
            <div class="col-sm-10">
                <input type="text" v-model="storeFavouredPrice.favouredId">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.sellerId" placeholder="商户id" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>账套名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.favouredName" placeholder="账套名称" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>折扣率</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="storeFavouredPrice.discountRate" placeholder="折扣率" />
                <span style="color: red">请输入0-1之间的数值</span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">描述</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="storeFavouredPrice.describes" placeholder="描述" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>开始时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="storeFavouredPrice.startTime" @click="checkBeginDate" placeholder="开始时间" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>结束时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="storeFavouredPrice.endTime" @click="checkEndDate" placeholder="结束时间" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary  btn-sm" @click="saveOrUpdate" value="确定" />
            &nbsp;&nbsp;<input type="button" class="btn btn-warning  btn-sm" @click="reload" value="返回" />
        </div>
    </form>
    <div class="panel-heading">该账套下的商品折扣率</div>
    <el-table :data="detailData" border style="width: 100%">
        <el-table-column type="index" width="50">
        </el-table-column>
        <el-table-column prop="storeCategoryId" label="商品分类">
        </el-table-column>
        <el-table-column prop="productName" label="商品名称">
        </el-table-column>
        <el-table-column prop="discountRate" label="折扣率">
            <template slot-scope="scope">
                <el-input size="small" v-model="scope.row.discountRate"></el-input>
            </template>
        </el-table-column>
        <el-table-column label="设置阶梯价折扣率" width="200">
            <template slot-scope="scope">
                <!--<el-popover>-->
                    <!--<p>{{ scope.row.stepPrice }}</p>-->
                    <!--<div slot="reference" class="name-wrapper">-->
                        <el-button size="small" slot="append" icon="el-icon-setting" @click="openStepPriceDialog(scope.row)">阶梯折扣率设置</el-button>
                    <!--</div>-->
                <!--</el-popover>-->

            </template>
        </el-table-column>
        <el-table-column
                label="操作"
                width="120">
            <template slot-scope="scope">
                <el-button
                        @click.native.prevent="updateDetail(scope.row)"
                        type="text"
                        size="small">
                    保存
                </el-button>
                <el-button
                        @click.native.prevent="deleteRow(scope.row.detailId)"
                        type="text"
                        size="small">
                    删除
                </el-button>
            </template>
        </el-table-column>
    </el-table>
    <hr>
    <el-row>
        <el-col :span="12">
            <div class="el-form-item">
                <label class="el-form-item__label" style="width: 80px;">商品分类</label>
                <div class="el-form-item__content" style="margin-left: 80px;">
                    <el-cascader style="width: 50%" filterable
                                 v-model="categoryId"
                                 :options="storeCategoryTree"
                                 @change="categoryChange">
                    </el-cascader>
                </div>
            </div>
            <div class="el-form-item">
                <label class="el-form-item__label" style="width: 80px;">商品名称</label>
                <div class="el-form-item__content" style="margin-left: 80px;">
                    <el-select v-model="productId" placeholder="请选择">
                        <el-option
                                v-for="item in storeGoodsProductEntityList"
                                :key="item.productId"
                                :label="item.productName"
                                :value="item.productId">
                        </el-option>
                    </el-select>
                </div>
            </div>
            <div class="el-form-item">
                <el-button-group style="margin-left: 80px">
                    <el-button  size="small" @click="addDetail">添加</el-button>
                    <el-button  size="small" @click="showList=true,detailView=false">取消</el-button>
                </el-button-group>
            </div>
        </el-col>
    </el-row>

</div>
<!--账套详情表end-->
<!--阶梯价格弹窗-->
<el-dialog title="阶梯折扣率设置" :visible.sync="stepPriceDialogVisible" width="600px">
    <div>
        <el-table ref="stepPriceTable" :data="stepPriceData" stripe="true" border="true" size="small"
                  highlight-current-row="true" style="width: 100%" max-height="400">
            <el-table-column label="开始数量" width="100">
                <template slot-scope="scope">
                    <el-input size="small" v-model="scope.row.beginNum"></el-input>
                </template>
            </el-table-column>

            <el-table-column label="结束数量" width="100">
                <template slot-scope="scope">
                    <el-input size="small" v-model="scope.row.endNum"></el-input>
                </template>
            </el-table-column>

            <el-table-column label="折扣率" width="100">
                <template slot-scope="scope">
                    <el-input size="small" v-model="scope.row.singlePrice"></el-input>
                </template>
            </el-table-column>

            <el-table-column label="备注" width="150">
                <template slot-scope="scope">
                    <el-input size="small" v-model="scope.row.remark"></el-input>
                </template>
            </el-table-column>

            <el-table-column label="操作" width="100">
                <template slot-scope="scope">
                    <el-button @click.native.prevent="addOneStepPrice" type="text" size="small">
                        添加
                    </el-button>
                    <el-button @click.native.prevent="deleteOneStepPrice(scope.$index, stepPriceData)" type="text" size="small">
                        删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer">
					<el-button size="small" @click="stepPriceDialogVisible = false">取消</el-button>
                <el-button size="small" type="primary" @click="saveStepPrice">保存</el-button>
				</span>
    </div>

</el-dialog>
</div>

<script src="${request.contextPath}/statics/js/modules/storeFavouredPrice/storefavouredprice.js?_${.now?long}"></script>
</body>
</html>
